package com.android.app;

import android.app.Application;
import android.content.Context;

import com.android.model.net.RetrofitUtil;
import com.android.util.CrashLogUtil;
import com.android.util.FrescoUtil;
import com.android.util.ToastUtil;
import com.android.util.log.LogUtil;
import com.lzy.okgo.OkGo;

/**
 * author:  TenFace
 * date:    2017/9/13
 * description: 全局初始化操作
 */

public class MyApplication extends Application {
    private static MyApplication instance;
    public static MyApplication getInstance() {
        return instance;
    }

    private static Context mContext;

    public static Context getContext() {
        return mContext;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        //内存泄露检测
//        if (LeakCanary.isInAnalyzerProcess(this)) return;
//        refWatcher = LeakCanary.install(this);
        mContext = this;
        instance = this;
        //OkGo初始化
        OkGo.init(this);
        OkGo.getInstance().setConnectTimeout(8 * 1000).setRetryCount(2);

        ToastUtil.init(this);//初始化吐司
        LogUtil.init(true);//初始化Log打印，true表示显示打印，false表示不显示打印
        CrashLogUtil.getInstance().init(this);//初始化崩溃输出
        RetrofitUtil.init(this);//初始化retrofit
        FrescoUtil.getInstance().initializeFresco(this);//初始化Fresco
//        EventBusUtil.openIndex();//开启Index加速

    }


    /**
     * 内存泄露检测
     */
//    private RefWatcher refWatcher;
//
//    public static RefWatcher getRefWatcher(Context context) {
//        MyApplication application = (MyApplication) context.getApplicationContext();
//        return application.refWatcher;
//    }


}
